//
//  DetailInfoCell.m
//  Cat
//
//  Created by lushitong on 2018/12/23.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "DetailInfoCell.h"
#import "FLImageView.h"
#import "ProductInfo.h"

@interface DetailInfoCell()

@property (nonatomic, strong) UILabel *infoLabel;
@property (nonatomic, strong) UILabel *nowMoneyLabel;
@property (nonatomic, strong) UILabel *yuanLabel;
@property (nonatomic, strong) UILabel *yijingLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) FLImageView *shopIcon;
@property (nonatomic, strong) UILabel *shopLabel;

@end

@implementation DetailInfoCell

- (void)setCellModelData:(id)cellModelData {
	ProductInfo *model = (ProductInfo *)cellModelData;
	self.nowMoneyLabel.text = [NSString stringWithFormat:@"￥%@",model.buyPrice];
	self.yuanLabel.text = [NSString stringWithFormat:@"淘宝价￥%@",model.marketAmount];
	self.yijingLabel.text = [NSString stringWithFormat:@"已领券%@",model.sellNum];
	self.titleLabel.text = model.title;
	[self.shopIcon setImageUrl:[NSURL URLWithString:model.storeImg] size:CGSizeMake(kQKFitModuleDecimal(24), kQKFitModuleDecimal(24)) cornerRadius:kQKFitModuleDecimal(12)];
	self.shopLabel.text = model.storeName;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
	if (self) {
		self.cellSeparatorStyle = QKUITableViewCellSeparatorStyleNone;
		self.selectionStyle = UITableViewCellSelectionStyleNone;
		[self loadSubviews];
	}
	return self;
}


- (void)loadSubviews {
	[self.contentView addSubviews:@[self.infoLabel,self.nowMoneyLabel,self.yuanLabel,self.yijingLabel,self.titleLabel,self.shopIcon,self.lineView,self.shopLabel]];
	
	[self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.contentView.mas_left).offset(kQKFitModuleDecimal(16.0));
		make.size.equalTo(CGSizeMake(kQKFitModuleDecimal(49), kQKFitModuleDecimal(21)));
		make.top.equalTo(self.contentView.mas_top).offset(kQKFitModuleDecimal(16));
	}];
	
	[self.nowMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.infoLabel.mas_right);
		make.centerY.equalTo(self.infoLabel.mas_centerY);
	}];
	
	[self.yuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.nowMoneyLabel.mas_right).offset(kQKFitModuleDecimal(4));
		make.centerY.equalTo(self.nowMoneyLabel.mas_centerY);
	}];
	
	[self.yijingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.right.equalTo(self.contentView.mas_right).offset(-kQKFitModuleDecimal(16));
		make.centerY.equalTo(self.yuanLabel.mas_centerY);
	}];
	
	[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.contentView.mas_left).offset(kQKFitModuleDecimal(16));
		make.top.equalTo(self.infoLabel.mas_bottom).offset(kQKFitModuleDecimal(13.0));
		make.right.equalTo(self.contentView.mas_right).offset(-kQKFitModuleDecimal(16));
		make.bottom.equalTo(self.contentView.mas_bottom).offset(-kQKFitModuleDecimal(62));
	}];
	
	[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.contentView.mas_left).offset(kQKFitModuleDecimal(16));
		make.top.equalTo(self.contentView.mas_bottom).offset(-kQKFitModuleDecimal(50));
		make.right.equalTo(self.contentView.mas_right);
		make.height.equalTo(@(kQKFitModuleDecimal(1)));
	}];
	
	[self.shopIcon mas_makeConstraints:^(MASConstraintMaker *make) {
		make.size.equalTo(CGSizeMake(kQKFitModuleDecimal(24), kQKFitModuleDecimal(24)));
		make.top.equalTo(self.lineView.mas_bottom).offset(kQKFitModuleDecimal(13));
		make.left.equalTo(self.titleLabel.mas_left);
	}];
	
	[self.shopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.shopIcon.mas_right).offset(kQKFitModuleDecimal(8));
		make.centerY.equalTo(self.shopIcon.mas_centerY);
	}];
}


- (UILabel *)infoLabel {
	if (!_infoLabel) {
		_infoLabel = [UILabel labelWithText:@"券后价" font:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0xF47272)];
		_infoLabel.layer.borderWidth = kQKFitModuleDecimal(1);
		_infoLabel.layer.borderColor = COLOR_WITH_HEX(0xF47272).CGColor;
		_infoLabel.textAlignment = NSTextAlignmentCenter;
	}
	return _infoLabel;
} 

- (UILabel *)nowMoneyLabel {
	if (!_nowMoneyLabel) {
		_nowMoneyLabel = [UILabel labelWithText:@"￥60" font:[UIFont systemFontOfSize:kQKFitFont(24)] textColor:COLOR_WITH_HEX(0xF86060)];
	}
	return _nowMoneyLabel;
}

- (UILabel *)yuanLabel {
	if (!_yuanLabel) {
		_yuanLabel = [UILabel labelWithText:@"淘宝价￥70" font:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0xCDC7C4)];
	}
	return _yuanLabel;
}

- (UILabel *)yijingLabel {
	if (!_yijingLabel) {
		_yijingLabel = [UILabel labelWithText:@"已领券3034" font:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0xCDC7C4)];
	}
	return _yijingLabel;
}

-(UILabel *)titleLabel {
	if (!_titleLabel) {
		_titleLabel = [UILabel labelWithText:@"圆点点小姐古董娃娃Lolita复古荷叶边" font:[UIFont systemFontOfSize:kQKFitFont(14)] textColor:COLOR_WITH_HEX(0x57524F)];
		_titleLabel.numberOfLines = 0;
	}
	return _titleLabel;
}

- (UIView *)lineView {
	if (!_lineView) {
		_lineView = [[UIView alloc] init];
		_lineView.backgroundColor = COLOR_WITH_HEX(0xEEEBEB);
	}
	return _lineView;
}

- (FLImageView *)shopIcon {
	if (!_shopIcon) {
		_shopIcon = [[FLImageView alloc] init];
	}
	return _shopIcon;
}

- (UILabel *)shopLabel {
	if (!_shopLabel) {
		_shopLabel = [UILabel labelWithText:@"同泰优品旗舰店" font:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0x57524F)];
	}
	return _shopLabel;
}


@end
